package com.sinoglobal.wallet.adapter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.sinoglobal.wallet.R;
import com.sinoglobal.wallet.entity.W_BalanceEntity.RsEntity;

public class W_BalanceDetailAdapter extends W_SinoBaseSimpleAdapter<RsEntity>{

	public W_BalanceDetailAdapter(Context mContext) {
		super(mContext);
	}

	@Override
	public void findViews(Map<java.lang.String, View> widgets, int position, View convertView) {
		TextView baldetail_title = (TextView) convertView.findViewById(R.id.baldetail_title);
		TextView baldetail_time = (TextView) convertView.findViewById(R.id.baldetail_time);
		TextView baldetail_money = (TextView) convertView.findViewById(R.id.baldetail_money);
		widgets.put("baldetail_title", baldetail_title);
		widgets.put("baldetail_time", baldetail_time);
		widgets.put("baldetail_money", baldetail_money);
	}
	

	@Override
	public void setValues(View convertView, ViewHolder holder, Map<String, View> widgets, int position) {
		TextView baldetail_title = (TextView) widgets.get("baldetail_title");
		TextView baldetail_time = (TextView) widgets.get("baldetail_time");
		TextView baldetail_money = (TextView) widgets.get("baldetail_money");
		
		
		RsEntity balance = (RsEntity) getItem(position);
		  SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");  
		  baldetail_time.setText(sdf.format(new Date(balance.getCreateDate())));
		if(balance.getModelDes()!=null&&!balance.getModelDes().equals("")){
			baldetail_title.setText(balance.getModelDes());

		}else{
			baldetail_title.setText(balance.getBussinessName());
			
		}
	
		if(balance.getAmountType()==1){
			baldetail_money.setTextColor(mContext.getResources().getColor(R.color.w_green1));
			baldetail_money.setText("-"+String.valueOf(balance.getAmount()));
			
		}else if(balance.getAmountType()==0){
			baldetail_money.setText("+"+String.valueOf(balance.getAmount()));
			baldetail_money.setTextColor(mContext.getResources().getColor(R.color.w_yellow_color));
		}else{
			baldetail_money.setText("+"+String.valueOf(balance.getAmount()));
		}
		
	
	}

	@Override
	public View setAdapterLayout(LayoutInflater inflater, int position) {
		return inflater.inflate(R.layout.wallet_baldetail_list_item_layout, null);
	}
	
}
